﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2023_09_13
{
    internal class MagicTriples
    {
        static int count = 0;
        static int n;
        static void Main4(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();

            FindPalindromeTriplets(str, 0, n - 1);
            Console.WriteLine(count);
        }

        static void FindPalindromeTriplets(string str, int left, int right)
        {
            if (left >= right)
            {
                return;
            }

            if (str[left] == str[right])
            {
                count++;
            }

            for (int i = 0; i < ((n + 1) / 2); i++)
            {
                FindPalindromeTriplets(str, left + 1, right - i);
            }
        }
    }
}
